package com.hytc.listener;
import com.hytc.entity.Cart;
import com.hytc.entity.Product;
import com.hytc.entity.User;
import com.hytc.service.UserService;
import com.hytc.service.impl.UserServiceImpl;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.List;

public class listener implements ServletContextListener {
     private UserService userService =  new UserServiceImpl();
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
       ServletContext context = servletContextEvent.getServletContext();
       List<Product> list = userService.query();
       context.setAttribute("product",list);;
       List<User> list1 = userService.find();
       context.setAttribute("user",list1);
        System.out.println("数据输入成功");
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
}
